package com.iwhalecloud.bss.kite.cucc.service.route.impl;

import java.util.Map;

import com.google.common.collect.Maps;
import com.iwhalecloud.bss.kite.common.chain.HandlerExecutionChain;
import com.iwhalecloud.bss.kite.cucc.client.dto.inf.InfServContextDTO;
import com.iwhalecloud.bss.kite.cucc.service.route.IInfServRoute;
import com.iwhalecloud.bss.kite.cucc.service.route.InfServReqParam;
import com.iwhalecloud.bss.kite.cucc.service.route.strategy.IInfServStrategy;
import com.iwhalecloud.bss.kite.cucc.service.route.strategy.impl.InfServiceBusStrategy;

public abstract class AbstractInfServRoute implements IInfServRoute {

    /**
     * Description: <br>
     * 订单提交
     * 
     * @author XXZ<br>
     * @taskId <br>
     * @param context
     * @return <br>
     */
    @Override
    public Map<String, Object> commitScene(InfServContextDTO context) {
        // 子类实现
        return Maps.newHashMap();
    }
    
    /**
     * 更新工单信息
     * 
     * @return <br>
     */
    @Override
    public Map<String, Object> updateWordOrder(InfServContextDTO context) {
        // 子类实现
        return Maps.newHashMap();
    }

    /**
     * Description: <br>
     * 路由策略匹配处理配注册
     * 
     * @taskId <br>
     *         <br>
     */
    public void registerStrategyMatchHandler(HandlerExecutionChain<InfServReqParam> newChain) {

    }

    /**
     * Description: <br>
     * 根据下单入参获取具体接口服务策略
     * 
     * @author XXX<br>
     * @taskId <br>
     * @param posDto
     * @return <br>
     */
    protected IInfServStrategy getInfServStrategy(InfServReqParam param) {
        // 默认外部中心服务总线
        IInfServStrategy infServStrategy = new InfServiceBusStrategy();
        param.setInfServStrategy(infServStrategy);

        // 创建路由匹配器
        HandlerExecutionChain<InfServReqParam> newChain = new HandlerExecutionChain<>();

        // 加载匹配处理类
        this.registerStrategyMatchHandler(newChain);

        // 启动路由策略
        newChain.doHandle(param);

        // 返回接口服务策略
        return param.getInfServStrategy();
    }

    /**
     * Description: <br>
     * 获取工单信息
     * 
     * @author XXZ<br>
     * @taskId <br>
     * @param context
     * @return <br>
     */
    @Override
    public Map<String, Object> getWorkOrderInfo(InfServContextDTO context) {
        // 子类实现
        return Maps.newHashMap();
    }
}
